﻿using Common.DTO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Database.Mappers
{
    public partial class Mapper
    {
        public IslandQue Map(IslandQueDTO que)
        {
            if (que == null ||
                que.Id == null)
                //que.Character == null ||
                //que.Island == null)
                return null;

            return new IslandQue
            {
                Id = que.Id,
                //Character = _characterMapper.Map(que.Character),
                //Island = _islandMapper.Map(que.Island)
            };
        }

        public IslandQueDTO Map(IslandQue que)
        {
            if (que == null ||
                que.Id == null ||
                que.Character == null /*||
                que.Island == null*/)
                return null;

            return new IslandQueDTO
            {
                Id = que.Id,
                Character = Map(que.Character),
                //Island = _islandMapper.Map(que.Island)
            };
        }

        public ICollection<IslandQue> Map(ICollection<IslandQueDTO> islandQues)
        {
            return islandQues.Select(x =>
                new IslandQue
                {
                    Id = x.Id,
                    CharacterId = x.Character.Id,
                    IslandId = x.Island.Id
                }).ToList();
        }

        public ICollection<IslandQueDTO> Map(ICollection<IslandQue> islandQueDTOs)
        {
            return islandQueDTOs.Select(x =>
                new IslandQueDTO
                {
                    Id = x.Id,
                    Character = Map(x.Character),
                    Island = Map(x.Island)
                }).ToList();
        }

        public ICollection<IslandQueDTO> Map(ICollection<IslandQue> islandQueDTOs, IslandDTO islandDTO)
        {
            return islandQueDTOs.Select(x =>
                new IslandQueDTO
                {
                    Id = x.Id,
                    Character = Map(x.Character),
                    Island = islandDTO
                }).ToList();
        }
    }
}
